package com.zhuoshi.controller;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.zhuoshi.entity.Bargain;
import com.zhuoshi.service.BargainService;

@Controller
@RequestMapping("bargain")
public class BargainController {
	@Autowired
	private BargainService bargainService;
	
	@RequiresPermissions("showOneBargain")
	@RequestMapping("showOneBargain")
	public String showOneBargain(Model model,Integer id){
		bargainService.addBargain(model, id);
		return "addBargain";		
	}
	
	
	@RequestMapping("showBargain")
	public String showBargain(Model model){
		List<Bargain> lists = bargainService.showBargain();
		model.addAttribute("lists", lists);
		return "showBargain";		
	}
	
	@RequestMapping("addBargain")
	public String addBargain(Bargain bargain){
		bargainService.addBargain(bargain);
		return "redirect:showBargain.action";		
	}

}
